<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%@ page import="Dao.usersDAO" %>
<%@ page import="JavaBean.users" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改操作</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    String id = request.getParameter("id");
    String name = request.getParameter("uName");
    String password = request.getParameter("uPwd");
    String gender = request.getParameter("uGender");
    String email = request.getParameter("uEmail");
    String resume = request.getParameter("uResume");
%>

<jsp:useBean id="users" class="JavaBean.users" scope="request"></jsp:useBean>
<jsp:setProperty name="users" property="*"></jsp:setProperty>
<%
    usersDAO dao = new usersDAO();
    int i = dao.update(name,password,gender,email,resume,id);
    //获取管理员用户的ID
    JavaBean.users adminUser = dao.getUsersByName("admin");
//    int adminID = adminUser.getId();
//    //将管理员的代码发送到页面内容中供EL表达式使用
//    pageContext.setAttribute("adminID",adminID);
//    pageContext.setAttribute("id",id);
    //dao的返回,用户信息是否更新成功
    pageContext.setAttribute("i",i);
%>
<c:choose>
    <c:when test="${i==0}">
        <script language='javascript'>alert('该用户已存在，请重新修改！');window.location.href='usersManager.jsp';</script>
    </c:when>
    <c:when test="${i==1}">
        <script language='javascript'>alert('信息修改成功！');window.location.href='usersManager.jsp';</script>
    </c:when>
    <c:otherwise>
        <script language='javascript'>alert('信息修改失败！');window.location.href='usersManager.jsp';</script>
    </c:otherwise>
</c:choose>
</body>
</html>